<?php
declare (strict_types = 1);

namespace app\common\listener;

class WsClose
{
    /**
     * 事件监听处理
     *
     * @return mixed
     */
    public function handle($event)
    {
        $this->chat =   app('app\common\model\chat\Chat');
        $this->system_admin =  app('app\common\model\system\SystemAdmin');
        //echo 'close关闭';
        $ws = app('think\swoole\Websocket');
        $ws->emit('sendfd', $ws->getSender());

        $id = $this->chat->where('fd',$ws->getSender())->value('user_id');
        $this->system_admin->where('id',$id)->save(['is_online'=>0]);

    }    
}
